package com.c.ctgproject.wiget.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import com.c.ctgproject.R
import com.c.ctgproject.http.DownloadAsyncTask
import com.c.ctgproject.http.DownloadListener
import kotlinx.android.synthetic.main.layout_update_dialog.*


/**
 *作者:LiBW
 *创建日期: 2020/8/22
 *描述:App更新页面
 */
class UpdateDialog(context: Context, themeResId: Int,private  val downloadUrl:String) : Dialog(context, themeResId) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.layout_update_dialog)
        val download= DownloadAsyncTask(object: DownloadListener {
            override fun onSuccess() {

            }

            override fun onFailed() {
                dismiss()
            }
            
            override fun onProgress(progress: Int) {
                val progressStr= "正在升级中...$progress%"
                mProgressTV.text=progressStr
            }
        },downloadUrl,context)
        download.execute(downloadUrl)
    }

    override fun onBackPressed() {

    }
}
